package generic;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

public class FilledList<T> extends ArrayList<T> {
    FilledList(Supplier<T> gen, int size) {
       Suppliers.fill(this,gen,size);
    }

    public FilledList(T t,int size){
        for(int i=0;i<size;i++) {
            this.add(t);
        }
    }
    public void f(Object arg) {
//        if(arg instanceof T) {}
//        T var = new T();
//        T[] array = new T[10];
//        T[] arrays = (T[])new Object[10]; 编译器报警
    }

    public static void main(String[] args) {
        List<String> list = new FilledList<>("Hello",4);
        System.out.println(list);
        List<Integer> iList = new FilledList<>(()->47,5);
        System.out.println(iList);
    }
}
